//
//  HXButton.m
//  爱鲜蜂
//
//  Created by 建国 on 16/5/4.
//  Copyright © 2016年 建国. All rights reserved.
//

#import "HXButton.h"

@implementation HXButton
//
//- (instancetype)initWithFrame:(CGRect)frame
//{
//    self = [super initWithFrame:frame];
//    if (self) {
//         }
//    return self;
//}
-(void)layoutSubviews{
   
    [super layoutSubviews];
  
    CGFloat ButtonX = self.frame.size.width;
    CGFloat ButtonY = self.frame.size.height ;
    self.titleLabel.textAlignment = NSTextAlignmentCenter ;
    self.imageView.frame = CGRectMake( 0 + ButtonX *0.1 , 0 , 3* ButtonX /4 , ButtonY * 0.6) ;
    self.titleLabel.frame = CGRectMake(0, ButtonY * 0.6, ButtonX, ButtonY * 0.4);
}

//快速构造方法

+(instancetype)buttonWithTitle:(NSString *)title NormalImage:(NSString *)normalImage  HighlightedImage:(NSString *)HighlightedImage andFontSize:(int)num{

    HXButton *button = [HXButton buttonWithType:(UIButtonTypeCustom)];
    [button sizeToFit];
    [button setTitle:title forState:(UIControlStateNormal)];
    [button setImage:[UIImage imageNamed:HighlightedImage] forState:(UIControlStateHighlighted)];
    [button setImage:[UIImage imageNamed:normalImage] forState:(UIControlStateNormal)];
    [button setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    button.titleLabel.font = [UIFont systemFontOfSize:num];
    return button;

}


@end
